{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false,
    "deletable": true,
    "editable": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Accuracy: 1.0\n",
      "True: 0, Predicted: 0\n",
      "True: 1, Predicted: 1\n",
      "True: 1, Predicted: 1\n",
      "True: 0, Predicted: 0\n"
     ]
    }
   ],
   "source": [
    "from sklearn.model_selection import train_test_split\n",
    "from sklearn.neural_network import MLPClassifier\n",
    "\n",
    "y = [0, 1, 1, 0]\n",
    "X = [[0, 0], [0, 1], [1, 0], [1, 1]]\n",
    "\n",
    "clf = MLPClassifier(solver='lbfgs', activation='logistic', hidden_layer_sizes=(2,), max_iter=100, random_state=20)\n",
    "clf.fit(X, y)\n",
    "\n",
    "predictions = clf.predict(X)\n",
    "print('Accuracy: %s' % clf.score(X, y))\n",
    "for i, p in enumerate(predictions[:10]):\n",
    "    print('True: %s, Predicted: %s' % (y[i], p))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false,
    "deletable": true,
    "editable": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Weights connecting the input layer and the hidden layer: \n",
      "[[ 6.11803955  6.35656369]\n",
      " [ 5.79147859  6.14551916]]\n",
      "Hidden layer bias weights: \n",
      "[-9.38637909 -2.77751771]\n",
      "Weights connecting the hidden layer and the output layer: \n",
      "[[-14.95481734]\n",
      " [ 14.53080968]]\n",
      "Output layer bias weight: \n",
      "[-7.2284531]\n"
     ]
    }
   ],
   "source": [
    "print('Weights connecting the input layer and the hidden layer: \\n%s' % clf.coefs_[0])\n",
    "print('Hidden layer bias weights: \\n%s' % clf.intercepts_[0])\n",
    "print('Weights connecting the hidden layer and the output layer: \\n%s' % clf.coefs_[1])\n",
    "print('Output layer bias weight: \\n%s' % clf.intercepts_[1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
